package org.wisigoth.chat.client.mockup;

import org.wisigoth.chat.client.Session;
import org.wisigoth.chat.client.UserPreferences;
import org.wisigoth.chat.client.Wisigoth;
import org.wisigoth.chat.client.exceptions.AccountCreationException;
/**
 * Mock up implementation of Wisigoth interface 
 * @author dtfs-tof
 *
 */
public class WisigothMockUp implements Wisigoth {
	/**
	 * Collection of combination of username and password 
	 */

	private UserPreferences userPreferences;
	
	
	public WisigothMockUp(){
		
		this.userPreferences = new UserPreferencesMockUp();
	}



	
	@Override
	public UserPreferences getUserPreferences() {
		return this.userPreferences;
	}

	@Override
	public void accountCreationRequest(String login, char[] password)
			throws AccountCreationException {
		if(ValidUsers.userExists(login)){
			throw new AccountCreationException("Username already exists");
		} else if (password.length == 0){
			throw new AccountCreationException("You must enter a password");
		}else {
			ValidUsers.createUser(login, new String(password));
		}
		
	}

	@Override
	public Session createSession() {
		return new SessionMockUp(this);
	}




	@Override
	public void close() {
		// TODO Auto-generated method stub
		throw new UnsupportedOperationException("Not implemented yet");
	}

}
